﻿using System;
using System.Collections.Generic;

namespace MxitAPI {
	
    // Used for login success and faliure
    public delegate void ConnectionEventHandler( Connection connection, EventArgs e );

    // Used for all contacts updates
    public delegate void ContactsEventHandler( Contacts contacts, ContactsEventArgs e );

    // EventArgs subclass that holds a contact affected by an event
    public class ContactsEventArgs : EventArgs {
        public Contact Contact { get; private set; }

        public ContactsEventArgs( Contact contact ) {
            Contact = contact;
        }
    }

    // Used by a ChatSession when a new message arrives
    public delegate void ChatSessionNewMessageEventHandler( ChatSession chatSession, EventArgs e );

    // Used by ChatSessions when a new message arrives
    // Used by a ChatSessions when a new chat Session has been created
    public delegate void ChatSessionsEventHandler( ChatSessions chatSessions, AffectedChatSessionsEventArgs e );

    /*
    public delegate void ChatSessionsNewMessageEventHandler( ChatSessions chatSessions, AffectedChatSessionsEventArgs e );

    // Used by a ChatSessions when a new chat Session has been created
    public delegate void NewChatSessionCreatedEventHandler( ChatSession chatSession, AffectedChatSessionsEventArgs e );
    */

    // Holds a list of chats that have new messages
    public class AffectedChatSessionsEventArgs : EventArgs {
        public List<ChatSession> AffectedChatSession { get; private set; }

        public AffectedChatSessionsEventArgs( List<ChatSession> affectedChatSession ) {
            AffectedChatSession = affectedChatSession;
        }
    }

    // Sent by a handler when a new subscription request comes in
    public delegate void NewSubscriptionEventHandler( Contacts contacts, NewSubscriptionEventArgs e  );

    public class NewSubscriptionEventArgs : EventArgs {
        public RawSubscription RawSubscription { get; set; }
        
        public NewSubscriptionEventArgs( RawSubscription rawSubscription ) {
            RawSubscription = rawSubscription;
        }
    }

    // Events that are sent when an error message is returned by the mxit servers
    public delegate void ProtocolMessageErrorEventHandler( Handler sender, ProtocolMessageErrorEventArgs e );
    
    public class ProtocolMessageErrorEventArgs : EventArgs {
        public ProtocolMessage ProtocolMessage { get; set; }

        public ProtocolMessageErrorEventArgs( ProtocolMessage protocolMessage ) {
            ProtocolMessage = protocolMessage;
        }
    }

    //public delegate void Contact

}
